package com.xiang.controller;

import com.xiang.doman.Good;
import com.xiang.service.GoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("good")
public class GoodController {

    @Autowired
    GoodService goodService;

    @GetMapping("/getById")
    public Good findById(@RequestParam int goodId){
        return goodService.getById(goodId);
    }

    @PutMapping("/reduceStock")
    void reduceStock(@RequestParam("goodId") int goodId,@RequestParam("num") int num){
        goodService.reduceStock(goodId,num);
    }
}
